﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data;

namespace backend_wcf
{
    [ServiceContract]
    public interface IService
    {
        /// <summary>
        /// Add a user to the internal database. The system does not support several users with the same username.
        /// </summary>
        /// <param name="userName">The requested username</param>
        /// <param name="password">The requested Password</param>
        /// <returns>True if adding was successful, else false.</returns>
        [OperationContract]
        bool addUser(string userName, string password, User.Type userType);

        /// <summary>
        /// Tries to login a user on this session.
        /// </summary>
        /// <param name="userName">The username of the user</param>
        /// <param name="password">The password of the user</param>
        /// <returns>Type of user which was logged in. If the user does not exists, return guest</returns>
        [OperationContract]
        User.Type login(string userName, string password);

        /// <summary>
        /// Adds a file to the internal database. Name is stored for viewing purposes, and for keeping track of format.
        /// </summary>
        /// <param name="name">The name of the file (without path)</param>
        /// <param name="data">The acctual file, as a byte array</param>
        [OperationContract]
        void addFile(string name, byte[] data);

        /// <summary>
        /// Gets a file from the database, given an id, obtainable from viewFiles. Names are to be kept track of in frontend.
        /// </summary>
        /// <param name="id">The id of the file</param>
        /// <returns>The file as byte data.</returns>
        [OperationContract]
        byte[] getFile(uint id);

        /// <summary>
        /// Gets a list of all the files.
        /// </summary>
        /// <returns>A list of dummyFiles, not containting any data.</returns>
        [OperationContract]
        List<DummyFile> viewFiles();

        [OperationContract]
        void deleteFile(uint id);

        [OperationContract]
        User.Type logout();
    }
}
